<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/SpringMVC07/js/jquery.js"></script>
</head>
<body>
    <button id="btn1">获取一个用户</button>
    <button id="btn2">获取所有用户</button>
    <table id="tb1" border="1" width="500px">
        <thead>
        <tr>
            <td>用户名</td>
            <td>密码</td>
            <td>年龄</td>
            <td>生日</td>
            <td>邮箱</td>
        </tr>
        </thead>

        <tbody>

        </tbody>
    </table>
</body>
<script>
    //后端返回的是json字符串
    $("#btn1").click(function(){
       $.ajax({
           url:"/SpringMVC07/json/getAUser",
           type:"POST",
           dataType:"json",//把后端返回的json字符串 当做 json对象来接受
           success:function(data){
              $("tbody").empty();
              let str = `<tr>
                             <td>${data.username}</td>
                             <td>${data.password}</td>
                             <td>${data.userAge}</td>
                             <td>${data.birthday}</td>
                             <td>${data.email}</td>
                        </tr>`
              $("tbody").append(str);
           }
       })
    })

    $("#btn2").click(function(){
        $.ajax({
            url:"/SpringMVC07/json/getUsers",
            type:"POST",
            dataType:"json",//把后端返回的json字符串 当做 json对象来接受
            success:function(data) {
                console.log(data);
                //把数据拼装到表格
            }
        })
    })
</script>
</html>